package logic

import (
	"context"
	"fmt"
	"user_srv/internal/dao"
	"user_srv/internal/svc"

	"user_srv/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserDetailLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUserDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserDetailLogic {
	return &UserDetailLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UserDetailLogic) UserDetail(in *user.UserDetailRequest) (*user.UserDetailResponse, error) {
	// todo: add your logic here and delete this line
	detail, err := dao.UserDetail(in)
	if err != nil {
		return nil, err
	}
	fmt.Println(detail)
	return &user.UserDetailResponse{
		Id:       int64(detail.Id),
		NickName: detail.NickName,
		ImageCur: detail.ImageCur,
		Gender:   int64(detail.Gender),
		Age:      int64(detail.Age),
		Email:    detail.Email,
		Mobile:   detail.Mobile,
	}, nil

}
